package xyz.bmj.model;

import lombok.Data;

@Data
public class MlUrl {
    private String urlContent = "https://api.bilibili.com/x/v3/fav/resource/list?media_id=%s&pn=%s&ps=20&keyword=&order=mtime&type=0&tid=0&platform=web&jsonp=jsonp";
    private int pn = 1;
    private int total = -1;
    private String mediaId = "159078549";

    public String getPrevPageUrl() {
        if (pn > 1) {
            pn--;
        }
        return toString();
    }

    public String getNextPageUrl() {
        if (hasNextPage()) {
            pn++;
        }
        return toString();
    }

    public boolean hasNextPage() {
        System.out.println((pn + 1) * 20);
        return pn * 20 < total;
    }


    @Override
    public String toString() {
        return String.format(urlContent, mediaId, pn);
    }
}
